package com.hpq.common.domain.vo.request;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

/**
 *  分页查询请求对象
 */
@Data
@ApiModel(description = "分页查询请求对象")
@AllArgsConstructor
@NoArgsConstructor
public class CursorPageBaseReq {
    @ApiModelProperty(value = "分页大小")
    @Min(value = 0, message = "分页大小不能小于0")
    @Max(value = 100, message = "分页大小不能大于100")
    private Integer pageSize = 10;
    @ApiModelProperty(value = "下一页的游标")
    private String nextCursor;

    /**
     *  获取MyBatisPlus分页对象
     * @return
     */
    public Page MyBatisPlusPage(){
        return new Page(1,this.pageSize,false);
    }

    @JsonIgnore
    public Boolean isLastPage(){
        return StringUtils.isEmpty(nextCursor);
    }
}
